#ifndef CmdSystem_h__
#define CmdSystem_h__

#include "../infLib/infLib.h"

typedef int cmdFlags_t;
enum cmdFlags_e {
	CMD_ALL			= -1,
	CMD_COMMON	    = BIT(0),	//!< Related to the framework
	CMD_RENDERER	= BIT(1), 	//!< Related to the renderer
	CMD_SOUND		= BIT(2),	//!< Related to the sound system
};

typedef void ( *cmdFunction_t )( const inf::CmdArgs& args );

struct Cmd {
	const char*     name;
	const char*     description;
	cmdFunction_t   function;
	cmdFlags_t      flags;
};

class CmdSystem {
public:
	        CmdSystem();
	        ~CmdSystem();

	void    Init();
	void    Shutdown();

	void	AddCmd( const char *cmdName, const char* description, cmdFlags_t flags, cmdFunction_t func );
	void	RemoveCmd( const char *cmdName );
	void	RemoveCmdsByFlags( int flags );

	void	ExecuteCmd( const char *cmdName );

	bool	ExportToHTML( const char *filename="cmds.html", int flags=CMD_ALL ) const;
private:
	const Cmd* FindCmd( const char* name ) const;

	typedef inf::List<Cmd> CmdTable;
	CmdTable cmds;
};

extern CmdSystem* cmdSystem;

#endif // CmdSystem_h__
